package com.example.demo.service;

import com.example.demo.bean.User;
import com.example.demo.dao.UserDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserService {
    @Autowired
    private UserDao userDao;
    public User findUserByName(String name){
        return userDao.findUserByName(name);
    }
    public List<User> findAll(){
        return userDao.findAll();
    }
    public User save(User user){
        return userDao.save(user);
    }
    public User findUserById(Long id){
        return userDao.findUserById(id);
    }
    public User updateUser(User user){
        return userDao.saveAndFlush(user);
    }
    public void deleteUser(Long id){
        userDao.deleteById(id);
    }
}
